home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch17 / Light.cls < prev    next >
Text File  |  1999-07-08  |  2KB  |  86 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "LightSource"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. ' Light source.
  17.  
  18. Private Location As Point3D
  19.  
  20. Public Ir As Single
  21. Public Ig As Single
  22. Public Ib As Single
  23.  
  24. Public Rmin As Single
  25. Public Kdist As Single
  26.  
  27. ' Apply a transformation matrix to the object.
  28. Public Sub Apply(M() As Single)
  29.     ' Transform the center.
  30.     m3Apply Location.Coord, M, Location.Trans
  31. End Sub
  32. ' Apply a transformation matrix to the object.
  33. Public Sub ApplyFull(M() As Single)
  34.     ' Transform the center.
  35.     m3ApplyFull Location.Coord, M, Location.Trans
  36. End Sub
  37.  
  38. ' Initialize the object using text parameters in
  39. ' a comma-delimited list.
  40. Public Sub SetParameters(ByVal txt As String)
  41.     On Error GoTo ParamError
  42.  
  43.     ' Read the parameters and initialize the object.
  44.     Location.Coord(1) = CSng(GetDelimitedToken(txt, ","))
  45.     Location.Coord(2) = CSng(GetDelimitedToken(txt, ","))
  46.     Location.Coord(3) = CSng(GetDelimitedToken(txt, ","))
  47.     Location.Coord(4) = 1
  48.  
  49.     ' Light intensities.
  50.     Ir = CSng(GetDelimitedToken(txt, ","))
  51.     Ig = CSng(GetDelimitedToken(txt, ","))
  52.     Ib = CSng(txt)
  53.  
  54.     Exit Sub
  55.  
  56. ParamError:
  57.     MsgBox "Error initializing light source parameters."
  58. End Sub
  59.  
  60. ' Return the light source's transformed coordinate.
  61. Property Get TransX() As Single
  62.     TransX = Location.Trans(1)
  63. End Property
  64. ' Return the light source's original coordinate.
  65. Property Get CoordX() As Single
  66.     CoordX = Location.Coord(1)
  67. End Property
  68.  
  69. ' Return the light source's original coordinate.
  70. Property Get CoordY() As Single
  71.     CoordY = Location.Coord(1)
  72. End Property
  73. ' Return the light source's original coordinate.
  74. Property Get CoordZ() As Single
  75.     CoordZ = Location.Coord(1)
  76. End Property
  77. ' Return the light source's transformed coordinate.
  78. Property Get TransY() As Single
  79.     TransY = Location.Trans(2)
  80. End Property
  81. ' Return the light source's transformed coordinate.
  82. Property Get TransZ() As Single
  83.     TransZ = Location.Trans(3)
  84. End Property
  85.  
  86.